package Song.Han.day04.demo05;

import java.util.ArrayList;

/*
* 题目：
*   自定义4个学生对象，添加到集合并遍历*/
public class Demo02ArrayListStudent {
    public static void main(String[] args) {

        ArrayList<Student> list = new ArrayList<>();

        Student one = new Student("小明",18);
        Student two = new Student("小刚",18);
        Student three = new Student("小红",18);
        Student four = new Student("小李",18);

        list.add(one);
        list.add(two);
        list.add(three);
        list.add(four);

        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            System.out.println("姓名："+stu.getName());
            System.out.println("年龄："+stu.getAge());
        }
    }
}
